<?php
include "../include/global.php";
include "../include/admin_check.php";

$type = $_GET['type'];

//echo $script = cfopen(const_Web_Url."admin/sitemap/".$type.".php", true);

//echo const_Web_Url."/admin/sitemap/".$type.".php";die;
$handle = fopen(const_Web_Url."/admin/sitemap/".$type.".php", "rb");
$script = '';
while (!feof($handle)) {
	$script .= fread($handle, 8192);
}
fclose($handle);

?> 

<?php
$script_file = const_Web_Path.$type.'.xml'; 
if (is_writable($script_file)){
    if (!$fp = fopen($script_file, 'w')) {
         print "Cannot open file ($script_file)";
         exit;
    }else{
	    if(!$ff=fflush ($fp)){
		    print "Cannot fflush file ($script_file)";
            exit;
		}
	}
    if (!fwrite($fp, $script)) {
        print "Cannot write to file ($script_file)";
        exit;
    }
    print "Success, created google sitemap ($script_file)";
    fclose($fp);
}else{
    print "The file $script_file is not writable";
}
///////

?>
<br /><br />
<a href="javascript:history.go(-1);">Back</a>